<template>
  <Dialog v-model="dialogVisible" title="批量评分" width="1000px">
    <el-form ref="formRef" :model="formData" label-width="100px">
      <el-form-item label="评价计划">
        <el-select v-model="formData.planId" placeholder="请选择评价计划">
          <el-option label="计划1" value="1" />
          <el-option label="计划2" value="2" />
        </el-select>
      </el-form-item>
      <el-form-item label="评价科目">
        <el-select v-model="formData.subjectId" placeholder="请选择评价科目">
          <el-option label="科目1" value="1" />
          <el-option label="科目2" value="2" />
        </el-select>
      </el-form-item>
    </el-form>
    
    <el-table :data="candidateList" border style="width: 100%; margin-top: 20px;">
      <el-table-column prop="candidateName" label="考生姓名" width="120" />
      <el-table-column prop="idCard" label="身份证号" width="180" />
      <el-table-column label="理论成绩" width="120">
        <template #default="{ row }">
          <el-input-number v-model="row.theoryScore" :min="0" :max="100" size="small" />
        </template>
      </el-table-column>
      <el-table-column label="实操成绩" width="120">
        <template #default="{ row }">
          <el-input-number v-model="row.practiceScore" :min="0" :max="100" size="small" />
        </template>
      </el-table-column>
      <el-table-column label="综合成绩" width="120">
        <template #default="{ row }">
          {{ ((row.theoryScore + row.practiceScore) / 2).toFixed(1) }}
        </template>
      </el-table-column>
      <el-table-column label="评分说明">
        <template #default="{ row }">
          <el-input v-model="row.scoreComment" size="small" placeholder="评分说明" />
        </template>
      </el-table-column>
    </el-table>
    
    <template #footer>
      <el-button @click="dialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="submitForm">批量提交</el-button>
    </template>
  </Dialog>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const dialogVisible = ref(false)
const formRef = ref()
const formData = ref({
  planId: '',
  subjectId: ''
})

const candidateList = ref([
  {
    candidateName: '张三',
    idCard: '123456789012345678',
    theoryScore: 0,
    practiceScore: 0,
    scoreComment: ''
  },
  {
    candidateName: '李四',
    idCard: '123456789012345679',
    theoryScore: 0,
    practiceScore: 0,
    scoreComment: ''
  }
])

const open = () => {
  dialogVisible.value = true
}

const submitForm = () => {
  // TODO: 实现批量提交逻辑
  dialogVisible.value = false
}

defineExpose({ open })
</script> 